Skip to content

Conversation

@Amansingh0807
Copy link
Contributor

Resolves None

Description

What is the purpose of this pull request?

This pull request:

  • This PR adds math/base/special/croundnf.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • Resolves None

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Jan 8, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 8, 2026

Coverage Report

Package Statements Branches Functions Lines
math/base/special/croundnf $\color{green}190/190$
$\color{green}+0.00%$
$\color{green}5/5$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}190/190$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

@Planeshifter Planeshifter self-requested a review January 13, 2026 06:21
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding croundnf! The implementation looks good overall. I found one issue that needs to be addressed before this can be merged - the native addon build will fail due to a missing dependency in manifest.json. See the inline comment for details.

Comment on lines 40 to 46
"dependencies": [
"@stdlib/math/base/napi/binary",
"@stdlib/math/base/special/roundnf",
"@stdlib/complex/float32/ctor",
"@stdlib/complex/float32/real",
"@stdlib/complex/float32/imag"
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "build" task is missing @stdlib/complex/float32/reim as a dependency. The C implementation in src/main.c includes stdlib/complex/float32/reim.h and calls stdlib_complex64_reim(), so this dependency is needed for the native addon to build correctly.

Looking at the equivalent @stdlib/math/base/special/croundn package, its "build" task includes @stdlib/complex/float64/reim in the dependencies.

Suggested change
"dependencies": [
"@stdlib/math/base/napi/binary",
"@stdlib/math/base/special/roundnf",
"@stdlib/complex/float32/ctor",
"@stdlib/complex/float32/real",
"@stdlib/complex/float32/imag"
]
"dependencies": [
"@stdlib/math/base/napi/binary",
"@stdlib/math/base/special/roundnf",
"@stdlib/complex/float32/ctor",
"@stdlib/complex/float32/reim",
"@stdlib/complex/float32/real",
"@stdlib/complex/float32/imag"
]

@Amansingh0807
Copy link
Contributor Author

Thanks for catching this, @Planeshifter! I've added @stdlib/complex/float32/reim to the build dependencies. The fix has been pushed.


// MODULES //

var addon = require( './../src/addon.node' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to wrap the addon result in a Complex64 instance to match the documented return type and other similar packages like croundn and cceiln. Currently it returns the raw object from the addon (with .re and .im properties) instead of a proper Complex64 instance.

You'll also need to add the Complex64 import at the top of the file.

Suggested change
var addon = require( './../src/addon.node' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var addon = require( './../src/addon.node' );

// MAIN //

/**
* Rounds each component of a single-precision complex floating-point number to the nearest multiple of \\(10^n\\).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use backticks here instead of LaTeX notation to match the style in croundn/lib/native.js and other lib files:

Suggested change
* Rounds each component of a single-precision complex floating-point number to the nearest multiple of \\(10^n\\).
* Rounds each component of a single-precision complex floating-point number to the nearest multiple of `10^n`.

Comment on lines 49 to 51
function croundnf( z, n ) {
return addon( z, n );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should wrap the addon result in a Complex64 instance:

Suggested change
function croundnf( z, n ) {
return addon( z, n );
}
function croundnf( z, n ) {
var v = addon( z, n );
return new Complex64( v.re, v.im );
}

Comment on lines 36 to 37
"libraries": [
"-lm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -lm flag isn't needed here since this package doesn't directly use math.h functions - it delegates to roundnf which handles that dependency in its own manifest.

Suggested change
"libraries": [
"-lm"
"libraries": [],

Comment on lines 57 to 58
"libraries": [
"-lm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - should be empty:

Suggested change
"libraries": [
"-lm"
"libraries": [],

Comment on lines 77 to 79
"libraries": [
"-lm"
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too:

Suggested change
"libraries": [
"-lm"
],
"libraries": [],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants